<%@ page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>

<div class="sidebarLogin">

    <security:authorize access="isAnonymous()">
        <p>Вход на сайт:</p>

        <form name='f' action="<c:url value='j_spring_security_check' />"
              method='POST'>
            <input type='text' name='j_username' placeholder="Логин" />
            <input type='password' name='j_password' placeholder="Пароль"/>

            <input name="submit" type="submit" class="submit" value="Вперед!"/>
            <p>
                <a href="/home/register/">Регистрация</a>
            </p>
        </form>


    </security:authorize>

    <security:authorize access="isAuthenticated()">

        Вы вошли как: <span class="username"><security:authentication property="principal.username" /></span>

        <%--ip, чтоб набить ебальник--%>
        <%--<security:authentication property="details.remoteAddress" />--%>

        <security:authorize access="hasRole('ROLE_ADMIN')">
            <p>[Администратор]</p>
            <a href="/../admin/users/">[Пользователи]</a>
            <br>
            <a href="/../admin/news/">[Новости]</a>
            <br>
        </security:authorize>

        <p>
            <a href="<c:url value="/j_spring_security_logout" />">
                <button class="logout">Выйти</button>
            </a>
        </p>

    </security:authorize>

</div>